package com.zenjava.update.ui;

import com.zenjava.update.AppProfile;
import javafx.scene.control.Label;
import javafx.scene.layout.GridPane;

public class AppProfileView extends GridPane
{
    private AppProfile appProfile;
    private Label nameLabel;
    private Label versionLabel;
    private Label descriptionLabel;

    public AppProfileView()
    {
        buildView();
    }

    public void setAppProfile(AppProfile appProfile)
    {
        this.appProfile = appProfile;
        if (appProfile != null)
        {
            nameLabel.setText(appProfile.getName());    
            versionLabel.setText(appProfile.getVersion());
            descriptionLabel.setText(appProfile.getDescription());
        }
        else
        {
            nameLabel.setText(null);
            versionLabel.setText(null);
            descriptionLabel.setText(null);
        }
    }

    public AppProfile getAppProfile()
    {
        return appProfile;
    }

    private void buildView()
    {
        getStyleClass().add("application-profile-view");
        setHgap(10);
        setVgap(6);

        int row = 0;

        add(new Label("Name:"), 0, row);
        nameLabel = new Label();
        add(nameLabel, 1, row++);

        add(new Label("Version:"), 0, row);
        versionLabel = new Label();
        add(versionLabel, 1, row++);

        add(new Label("Description:"), 0, row);
        descriptionLabel = new Label();
        add(descriptionLabel, 1, row);
    }
}
